<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class GoodsPostRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'title'=>'required',
            'price'=>'required|regex:/\d+/',
            'kucun'=>'required|regex:/\d+/',
            'content'=>'required',
            'pic'=>'required'

        ];
    }
    /**
     * 获取已定义验证规则的错误消息。
     *
     * @return array
     */
    public function messages()
    {
        return [
            'title.required' => '标题是必填的',
            'price.required' => '价格是必填的',
            'price.regex' => '价格必须是数字',
            'kucun.required' => '库存是必填的',
            'price.regex' => '库存必须是数字',
            'content.required'  => '详情是必填的',
            'pic.required'  => '图片是必需上传的',
        ];
    }
}
